import {useMemo} from 'react';

const useSchoolDataReportModel = data => {
  const optionSex = useMemo( () => ({
    title: {
      text: '男女比例分布',
      bottom: '0',
      left: 'center'
    },
    legend: {
      type: 'plain',
      top: 0,
      left: 0
    },
    series: {
      radius: 90,
      type: 'pie',
      label: {
        show: true,
        position: 'inside',
        formatter: '{c}'
      },
      tooltip: {
        show: false,
        label: {
          formatter: '{d}%'
        }
      },
      data: [
        {
          name: '男',
          value: data?.data_boy,
        },
        {
          name: '女',
          value: data?.data_girl,
          itemStyle: {
            color: '#ff8b8e'
          }
        },
      ],
    },
  }), [data]);

  const optionYear = useMemo(() => ({
    title: {
      text: '成员年级分布',
      bottom: '0',
      left: 'center'
    },
    legend: {
      type: 'plain',
      top: 0,
      left: 0
    },
    series: {
      radius: 90,
      type: 'pie',
      label: {
        show: true,
        position: 'inside',
        formatter: '{c}'
      },
      data: data?.data_year,
    },
  }), [data]);

  return {
    optionSex,
    optionYear
  };
};

export default useSchoolDataReportModel;